package org.streets.eis.component.grid;

import org.apache.wicket.IClusterable;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;

import com.inmethod.grid.datagrid.DataGrid;

/*
 * 不可改变每页显示记录的
 */
public class DefualtNavigatorLabel extends Label {
	private static final long serialVersionUID = 1L;

	public DefualtNavigatorLabel(final String id, final DataGrid table) {
		super(id);
		setDefaultModel(new StringResourceModel("NavigatorLabel", this, Model.of(new LabelModelObject(table)),
				"当前显示第${pageNo}页,共${pageCount}页,共有${recCount}条记录"));
	}

	private class LabelModelObject implements IClusterable {
		private static final long serialVersionUID = 1L;
		private final DataGrid table;

		public LabelModelObject(DataGrid table) {
			this.table = table;
		}

		public String getRecCount() {
			int total = table.getTotalRowCount();
			return total != -1 ? "" + total : "未知";
		}

		public int getPageNo() {
			return table.getCurrentPage() + 1;
		}

		public int getPageCount() {
			return table.getPageCount();
		}

	}

}
